package com.lingjtx.im.core.protocol;

import com.lingjtx.common.core.constant.Const;

public class ProtocolWrapper {

    private final int magic = Const.IMMsgType.MAGIC;
    private final byte version = 0x01;     // 协议版本
    private final byte imType;     // 消息类型（1-心跳、2-单聊、3-群聊、4-客服坐席、5-系统通知）
    private final MessageProto.IMMessage message;  // Protobuf 消息体（具体业务数据）

    public ProtocolWrapper(byte imType, MessageProto.IMMessage message) {
        this.imType = imType;
        this.message = message;
    }

    public int getMagic() {
        return magic;
    }

    public byte getVersion() {
        return version;
    }

    public byte getImType() {
        return imType;
    }

    public MessageProto.IMMessage getMessage() {
        return message;
    }

    /**
     * 静态工厂方法：根据消息类型和 Protobuf 对象创建包装类
     */
    public static ProtocolWrapper of(byte imType, MessageProto.IMMessage message) {
        return new ProtocolWrapper(imType, message);
    }
}
